package com.dao.util;

import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * 
 * @author zgz 
 * 时间：2011-7-4
 * 功能描述：hibernate辅助类
 * 通过configuration拿到SessionFactory
 */
public class HibernateUtil {

	
	private static final SessionFactory sessionFactory;

	static {
		try {
			sessionFactory = new Configuration().configure().buildSessionFactory();

		} catch (HibernateException ex) {
			throw new RuntimeException(
					"创建SessionFactory出错: " + ex.getMessage(), ex);
		}
	}
	
	public static SessionFactory getSessionFactory(){
		return sessionFactory;
	}
}
